﻿using System;
using System.Collections.Generic;
using System.Text;
using ArgusPCLib.Mathematics.StructWrappers;

namespace ArgusPCLib.Mathematics
{
	public class Interval<T>
		where T : ILinearScalar
	{
		public T LowerLimit { get; private set; }
		public T UpperLimit { get; private set; }
		public T Range { get { return (T)this.UpperLimit.Subtract(this.LowerLimit); } }

		public Interval(T a, T b)
		{
			if (a.IsSmallerThan(b) == true)
			{
				this.LowerLimit = (T)a.GetDeepCopy();
				this.UpperLimit = (T)b.GetDeepCopy();
			}
			else
			{
				this.LowerLimit = (T)b.GetDeepCopy();
				this.UpperLimit = (T)a.GetDeepCopy();
			}
		}
	}

	public class Int32Interval : Interval<Int32Wrapper>
	{
		public new int LowerLimit { get { return base.LowerLimit; } }
		public new int UpperLimit { get { return base.UpperLimit; } }
		public new int Range { get { return this.UpperLimit - this.LowerLimit; } }

		public Int32Interval(int a, int b)
			: base(a, b) { }
	}

	public class DoubleInterval : Interval<DoubleWrapper>
	{
		public new double LowerLimit { get { return base.LowerLimit; } }
		public new double UpperLimit { get { return base.UpperLimit; } }
		public new double Range { get { return this.UpperLimit - this.LowerLimit; } }

		public DoubleInterval(double a, double b)
			: base(a, b) { }
	}
}
